/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aimozg.joglfw.gui;

import aimozg.utils.Listener;
import java.awt.event.KeyEvent;

/**
 *
 * @author aimozg
 */
public class GLTextInput extends GLBlock {
    public GLTextInput(GLComponent owner){
        super(owner);
        onKeyType.add(new Listener<GLComponent, KeyEvent>() {

            public void event(GLComponent sender, KeyEvent arg) {
                if (!isFocused())return;
                char c = arg.getKeyChar();
                if (c == '\b'){
                    if (!getText().isEmpty()){
                        setText(getText().substring(0, getText().length()-1));
                    }
                } else if (c>=' '){
                    setText(getText()+arg.getKeyChar());
                }
            }
        });
    }
    
    
}
